#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from lj_action import action_data
from lj_tool import tool_cache
from lj_tool.tool_opt import v

orm_site_device = action_data.init_action_data(
    "site_device", "cc3ac1352b104abfb86da5c351f8f68c")
entity = orm_site_device.entity

action_om_user = action_data.init_action_data(
    "om_user", "cc3ac1352b104abfb86da5c351f8f68c")
om_user_entity = action_om_user.entity

action_site_info = action_data.init_action_data(
    "site_info", "cc3ac1352b104abfb86da5c351f8f68c")
site_info_entity = action_site_info.entity


@tool_cache.lj_wrapper_cache(key="action_fm_list_mn_contrast_camera_code", expiration_seconds=60 * 5)
def list_mn_contrast_camera_code():
    return entity.select(entity.mn, entity.camera_code)


@tool_cache.lj_wrapper_cache(key="action_fm_get_site_by_mn", expiration_seconds=60 * 5)
def get_site_by_mn(mn):
    return action_site_info.get(mn)


@tool_cache.lj_wrapper_cache(key="action_fm_get_om_user_by_mn", expiration_seconds=60 * 5)
def get_om_user_by_mn(mn):
    return action_om_user.get(v(get_site_by_mn(mn), "om_user_id"))
